<?php
namespace app\admin\validate;
use think\Validate;
class AdminRules extends Validate
{
	// 正则列
	protected $regexv =
	[
		'idcheck'=> '^[123456789]$|^[123456789][0-9]{0,3}$',
		'pidcheck'=>'[0-9]{1,4}',
		'namecheck'	=> '^[a-zA-Z][\w]{1,31}[\/][a-zA-Z][\w]{1,31}$',
		'switch' => '[0]|[1]',
		'sort' => '([123456789])|([123456789][\d]{1})|(100)',
		'number'=>'^[123456789]$|^[123456789][\d]{0,10}$',
		'pidcheck'=>'[\d]{1,4}',
	];
	// 规则列
	protected $rule =
	[
		'id'		=>	'require|regex:number',
		'pid'		=>	'require|regex:pidcheck',
		'title'		=>	'require|chsDash',
		'name'		=>	'require|regex:namecheck',
		'status'	=>	'require|regex:switch',
		'sort'		=>	'require|regex:sort',
		'note'		=>	'require|length:2,255',
		'condition' =>	'require',
		'level'		=>	'require',
	];
	// 消息列
	protected $message =
	[
		'id.require'			=>	'ID_Must_Input',
		'id.regex'				=>	'ID_Format_Error',

		'pid.require'			=>	'Pid_Must_Input',
		'pid.regex'				=>	'Pid_Format_Error',

		'title.require'			=>	'Title_Must_Input',
		'title.chsDash'			=>	'Title_Format_Error',

		'name.require'			=>	'Name_Must_Input',
		'name.regex'			=>	'Name_Format_Error',

		'status.require'		=>	'Status_Must_Input',
		'status.regex'			=>	'Status_Format_Error',

		'sort.require'			=>	'Sort_Must_Input',
		'sort.regex'			=>	'Sort_Format_Error',

		'note.require'			=>	'Note_Must_Input',
		'note.length'			=>	'Length_Not_Range',

	];
	// 场景列
	protected $scene =
	[
		'ruleadd'		=>	['pid','title','name','status','sort','note'],
		'ruleedit'		=>	['id','title','name','status','sort','note'],
		'ruleid'		=>	['id'],
	];
}